package com.haiyou.dc.thread;

public class AllState {

    public static void main(String[] args) throws InterruptedException {

        Thread thread = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        //NEW
        System.out.println(thread.getState());

        //RUNNABLE
        thread.start();
        System.out.println(thread.getState());

        //TIMED_WAITING
        while (thread.getState() != Thread.State.TERMINATED) {
            Thread.sleep(200);
            System.out.println(thread.getState());
        }

        //TERMINATED
        System.out.println(thread.getState());
    }
}
